import {createRouter, createWebHashHistory} from 'vue-router'
import Layout from '@/Layout/index.vue'

const constantRouters = [
    {
        path: '/',
        component: Layout,
        redirect: '/home',
        meta: {showTabbar: true},
        children: [
            // 首页
            {
                path: 'home',
                name: 'home',
                component: () => import('@/views/home/index.vue'),
            },
            // 朋友
            {
                path: 'friends',
                name: 'friends',
                component: () => import('@/views/friends/index.vue'),
            },
            // 消息
            {
                path: 'message',
                name: 'message',
                component: () => import('@/views/message/index.vue'),
            },
            // 我的
            {
                path: 'mine',
                name: 'mine',
                component: () => import('@/views/mine/index.vue'),
            },
        ]
    },
    // 登录页面
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login/index.vue')
    },
    // 播放页面
    {
        path: '/play',
        name: 'play',
        component: () => import("@/views/mine/play.vue")
    },
    // 聊天页面
    {
        path: '/chat',
        name: 'chat',
        component: () => import("@/views/message/chat.vue")
    },
    // 系统通知
    {
        path: '/notice',
        name: 'notice',
        component: () => import("@/views/message/notice.vue")
    },
    // 编辑资料
    {
        path: "/editInfo",
        name: "editInfo",
        component: () => import("@/views/mine/editInfo.vue")
    },
    //编辑单项资料
    {
        path: "/editUserItem",
        name: "editUserItem",
        component: () => import("@/views/mine/editUserItem.vue")
    },
    // 商品详情
    {
        path: '/goodsInfo',
        name: 'goodsInfo',
        component: () => import('@/views/home/goodsInfo/index.vue')
    }

]
export const asyncRoutes = [{path: '/:pathMatch(.*)', redirect: '/404', hidden: true}]
export default createRouter({
    //createWebHashHistory 采用路由hash模式#
    history: createWebHashHistory(),
    //每次进入页面将页面重置到顶部
    scrollBehavior: () => ({top: 0}),
    //将静态路由注册到路由上
    routes: constantRouters
})
